package com.wyait.manage.config.idempotent;

import com.wyait.manage.idempotent.aop.IdempotentAdvice;
import org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 防重复提交外部aspect配置
 * @author huangjian
 */
@Configuration
public class IdempotentAspectConfig {

    @Value("${app.idempotent.base.package}")
    private String pointcut;

    @Bean
    public AspectJExpressionPointcutAdvisor idempotentAvisor(IdempotentAdvice idempotentAdvice) {
        AspectJExpressionPointcutAdvisor advisor = new AspectJExpressionPointcutAdvisor();
        advisor.setExpression(pointcut);
        advisor.setAdvice(idempotentAdvice);
        return advisor;
    }
}